/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.uch.syscom.hibernateSpringDao;

import java.util.ArrayList;
import java.util.List;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import pe.edu.uch.syscom.mapping.TbMarca;

/**
 *
 * @author Jose Tejada
 */
public class HSMarcaDAOImpl extends HibernateDaoSupport implements HSMarcaDAO {
    public List<TbMarca> listarMarcas(){
        List<TbMarca> lstMarcas;
        try {
            lstMarcas = this.getSession().
                    createCriteria( TbMarca.class ).
                    add( Restrictions.eq( "activo", 1 ) ).
                    list();
        } catch ( Exception ex ) {
            ex.printStackTrace();
            lstMarcas = new ArrayList<TbMarca>();
        }
        return lstMarcas;
    }
    public void saveMarca( String sMarca ){
        TbMarca marca = new TbMarca();
        marca.setMarca( sMarca );
        marca.setActivo( 1 );
        this.getHibernateTemplate().saveOrUpdate( marca );
    }
}
